Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-1242 App crashes on logout #423

Merged
merged 6 commits into from
May 6, 2022
Merged

O3-1242 App crashes on logout #423

merged 6 commits into from
May 6, 2022

Conversation

brandones
Copy link
Collaborator

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

This fixes the broken logout functionality. It also fixes a problem where clicking "Change location" from the user menu in the primary navigation bar would lead to an "An error has occurred. Please try reloading the page." page.

The general idea of the fix is to make it so that useSession uses Suspense, so that it always either throws or returns a valid session object—it can no longer return null.

There is a substantial bit of refactoring worked in. I changed getCurrentUser to use Unistore rather than RxJS for state management, mostly because I have a much better understanding of how Unistore works, and am confident that it will behave synchronously when I expect it to (the behavior of Observables is ambiguous in this regard).

I did my best to document the hook's implementation, since its complexity is increased substantially.

Screenshots

Peek 2022-05-05 16-45

Related Issue

https://issues.openmrs.org/browse/O3-1242

Other

Ideally, this should be tested by E2E tests. CC @jayasanka-sack .

@brandones brandones requested review from ZacButko and ibacher May 6, 2022 00:12
Comment on lines +166 to +168
devMiddleware: {
writeToDisk: true,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated: this makes it so that yarn run:shell plays nicer with yarn serveing the apps.

@jayasanka-sack
Copy link
Member

Ideally, this should be tested by E2E tests. CC @jayasanka-sack .

Noted with thanks! 😊

Copy link
Contributor

@ZacButko ZacButko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this Brandon

<BrowserRouter basename={window.spaBase}>
<Route
exact
path="/login(/confirm)?"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking, I haven't seen this syntax from react-router-dom before... doesn't look like plain text and doesn't look like regex?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write this, but it looks like regex to me. Parentheses for grouping and a question mark for "optional;" i.e. this will match /login or /login/confirm.

@brandones brandones merged commit 1a4a071 into master May 6, 2022
@brandones brandones deleted the fix-logout branch May 6, 2022 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants